/* Compile me with:  jflex mini.lex  */
package lex;

%%

%class Scanner

%type Token

%{
Token tok(String tag) { 
	return new Token(tag, yytext(), yycolumn+1,yyline+1);
}
%}
	
%column

%line

Reserved_Keywords= class | extends | static | void | int | boolean | string | return |if 
                   |else | while |break |continue |this |new |length |true |false |null

DIG = [0-9]+
INTEGER = 0("." {DIG})? | ( [1-9]+ {DIG}* ("." {DIG})? )

ID = [a-z][a-z0-9_]*
CLASS_ID=[A-Z]+[A-Za-z0-9_]*

DQUOTE = "\""
STR = {DQUOTE} ~([^\\]?{DQUOTE}) /* need to define better, look at the "04_strings.ic" example from moodle */ 

OP = "]" | "[" | "(" | ")" | "." | "-" | "!" | "*" |"/" | "%" 
    |"+" | "<" | "<="| ">="| ">" | "=" | "=="|"!=" |"&&"| "||" 

COMMENT = "#" .*               /* need to define */

OTHER= ";" | "," |"{" | "}" 
	
%%


{Reserved_Keywords}  { return tok(yytext()); }
{CLASS_ID}           { return tok("CLASS_ID"); }
{INTEGER}            { return tok("INTEGER"); }
{STR}          	     { return tok("STRING"); } 
{OP}                 { return tok(yytext()); }
{OTHER}              { return tok(yytext()); }
{ID}                 { return tok("ID"); }
{COMMENT}            { /* not defined */ }


[ ]         { /* nothing; skip */ }

.           { throw new Error((yyline+1)+":"+(yycolumn+1)+" : " + 
             "lexical error; invalid character "+"'"+yytext()+"'"); }

/* need to make some error messages more specific , look in the example in moodle */ 


